#!/bin/bash
dir=$(cd `dirname $0`; cd .. ; pwd)
cd $dir

docker network create todocoder-monitor

# 创建prometheus存储数据目录
mkdir -p /data/prometheus/data/
mkdir -p /data/prometheus/conf/
chmod 777 /data/prometheus/data

# /data/prometheus/conf/prometheus.yml
cat << EOF > /data/prometheus/conf/prometheus.yml
rule_files:
  - rule/record/*.yml
scrape_configs:
  - job_name: "todocoder-prometheus"
    static_configs:
      - targets: ["todocoder-prometheus:9090"]
  - job_name: "todocoder-cadvisor"
    static_configs:
      - targets: ["todocoder-cadvisor:8080"]
  - job_name: "todocoder-node" # 这个是监控node
    static_configs:
      - targets: ['todocoder-node:9100']
EOF

docker-compose -f $dir/docker-monitor.yaml up -d
# docker-compose -f docker-monitor.yaml up -d
